<template>
  <div class="head detail">
    <div class="detail-head">
      <van-icon size="28px" name="arrow-left" color="#676767" @click="$router.go(-1)" />
      <div class="detail-head-tab">
        <p
          v-for="(item,index) in list"
          :key="index"
          @click="change(index)"
          :class="{active:num ==index}"
        >{{item.title}}</p>
      </div>
      <van-icon name="weapp-nav" size="28px" color="#676767" />
      <van-icon name="cart-o" size="28px" color="#676767" @click="$router.push({path:'/cart'})" :info="carts.lists.length" />
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      num: 0,
      list: [
        {
          title: "商品"
        },
        {
          title: "详情"
        }
      ]
    };
  },
  computed: {
    ...mapState(["carts"])
  },
  methods: {
    change(index) {
      var t = document.querySelector('.content-main');
      this.num = index;
      if(index == 0){
        window.scroll(0, 0);
      }else if(index == 1){
        
      }
    }
  }
};
</script>

<style lang="less" scoped>
.detail {
  &-head {
    z-index: 10;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 4px;
    .van-icon-arrow-left {
      cursor: pointer;
      color: #333;
    }
    .van-icon-weapp-nav {
      position: relative;
      right: 14px;
    }
    .van-icon-cart-o {
      position: absolute;
      right: 55px;
      top: 20px;
    }
    &-tab {
      color: #333;
      font-size: 18px;
      margin: 0 auto;
      width: 288px;
      display: flex;
      align-items: center;
      justify-content: space-around;
      .active {
        position: relative;
      }
      .active::before {
        position: absolute;
        bottom: -3px;
        left: -2px;
        content: "";
        z-index: -1;
        width: 40px;
        height: 6px;
        box-shadow: 0.05555556rem 0.09259259rem 0.16666667rem 0
          rgba(131, 241, 219, 0.59);
        background-image: linear-gradient(90deg, #4bfdf2 0, #4bff8f 100%),
          linear-gradient(#94ffc4, #94ffc4);
      }
    }
  }
}
</style>